/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.ibrae.mchs.radiation.entities;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author murr
 */
@Entity
@Table(name = "rajon", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"ID_RAJON"})})
@NamedQueries({
    @NamedQuery(name = "Rajon.findAll", query = "SELECT r FROM Rajon r"),
    @NamedQuery(name = "Rajon.findByIdRajon", query = "SELECT r FROM Rajon r WHERE r.idRajon = :idRajon"),
    @NamedQuery(name = "Rajon.findByName2", query = "SELECT r FROM Rajon r WHERE r.name2 = :name2"),
    @NamedQuery(name = "Rajon.findByNumberPp", query = "SELECT r FROM Rajon r WHERE r.numberPp = :numberPp")})
public class Rajon implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_RAJON", nullable = false)
    private Integer idRajon;
    @Basic(optional = false)
    @Column(name = "NAME2", nullable = false, length = 50)
    private String name2;
    @Column(name = "NUMBER_PP", length = 3)
    private String numberPp;
    @OneToMany(mappedBy = "rajon")
    private Set<Result> resultSet;
    @JoinColumn(name = "ID_SUBJECT", referencedColumnName = "ID", nullable = false)
    @ManyToOne(optional = false)
    private SubjectRf subjectRf;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rajon")
    private Set<GSPos> gSPosSet;
    @OneToMany(mappedBy = "rajon")
    private Set<Geoobject> geoobjectSet;

    public Rajon() {
    }

    public Rajon(Integer idRajon) {
        this.idRajon = idRajon;
    }

    public Rajon(Integer idRajon, String name2) {
        this.idRajon = idRajon;
        this.name2 = name2;
    }

    public Integer getIdRajon() {
        return idRajon;
    }

    public void setIdRajon(Integer idRajon) {
        this.idRajon = idRajon;
    }

    public String getName2() {
        return name2;
    }

    public void setName2(String name2) {
        this.name2 = name2;
    }

    public String getNumberPp() {
        return numberPp;
    }

    public void setNumberPp(String numberPp) {
        this.numberPp = numberPp;
    }

    public Set<Result> getResultSet() {
        return resultSet;
    }

    public void setResultSet(Set<Result> resultSet) {
        this.resultSet = resultSet;
    }

    public SubjectRf getSubjectRf() {
        return subjectRf;
    }

    public void setSubjectRf(SubjectRf subjectRf) {
        this.subjectRf = subjectRf;
    }

    public Set<GSPos> getGSPosSet() {
        return gSPosSet;
    }

    public void setGSPosSet(Set<GSPos> gSPosSet) {
        this.gSPosSet = gSPosSet;
    }

    public Set<Geoobject> getGeoobjectSet() {
        return geoobjectSet;
    }

    public void setGeoobjectSet(Set<Geoobject> geoobjectSet) {
        this.geoobjectSet = geoobjectSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRajon != null ? idRajon.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Rajon)) {
            return false;
        }
        Rajon other = (Rajon) object;
        if ((this.idRajon == null && other.idRajon != null) || (this.idRajon != null && !this.idRajon.equals(other.idRajon))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "JPAtest.entities.Rajon[idRajon=" + idRajon + "]";
    }

}
